package lesson3.com.demo.logging;

import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;


public class LoggerExample_GLOBAL_NAME {
    
    public static void main(String[] args){
        System.out.println("Logger.GLOBAL_LOGGER_NAME="+Logger.GLOBAL_LOGGER_NAME);
        Logger myLogger = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
        printBasics(myLogger);
    }
    
    static void printBasics(Logger logger){
        List<Level> levelsList = new ArrayList<Level>();
        levelsList.add(Level.ALL);
        levelsList.add(Level.CONFIG);
        levelsList.add(Level.FINE);
        levelsList.add(Level.FINER);
        levelsList.add(Level.FINEST);
        levelsList.add(Level.INFO);
        levelsList.add(Level.OFF);
        levelsList.add(Level.SEVERE);
        levelsList.add(Level.WARNING);
        for(Level level: levelsList){
            System.out.println("Level: "+level.getName());
            System.out.println("\tlocalized name: "+level.getLocalizedName());
            System.out.println("\tresource bundle name: "+level.getResourceBundleName());
            System.out.println("\tint value: "+level.intValue());
            System.out.println();
        }
        System.out.println("Example logs for a logger with level set to "+logger.getLevel());
        for(Level level: levelsList){
           logger.log(level, "This is a(n) "+level.getName()+" log message");
        }
        
        System.out.println("\n------\nExample logs after setting level on logger to Level.INFO");
        logger.setLevel(Level.INFO);
        for(Level level: levelsList){
          logger.log(level, "This is a(n) "+level.getName()+" log message");
        }
    }

}
